<div class="content-titulo">
    
    <div class="filtro">
        <form id="form_filtro" method="get" action="">
            <i>Filtrar</i>
            
            <input type="text" name="dscfiltro" value="<?php echo $this->dscfiltro; ?>" placeholder="Grade Tamanho" />
            
            
            <input type="submit" class="btn-pdr" name="buscar" value="buscar" />
        </form>
    </div>
    
    
    <div class="content-btn">
        <a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit')); ?>">+</a>
    </div>
    
    <h2><?php echo $this->titulo;?></h2>
    
</div>

<div class="content-list">
    
<?php foreach ($this->result as $row) { 
    //$seg = new Sistema_Model_DbTable_Catsegmento();
    //$seg = $seg->fetchRow('CTS_ID ='.$row['CTS_ID']);
    $bool_seg = false;
    $segmentos = '';   
    $where_seg = 'CTS_ID in(0';
    $gtc = new Sistema_Model_DbTable_GradetamanhosHasCat();
    $gtc = $gtc->fetchAll('GRA_ID ='.$row['GRA_ID']);
    foreach($gtc as $g){
        $where_seg .= ','.$g['CTS_ID'];
        $bool_seg = true;
    }
    $where_seg .= ')';
    if($bool_seg){
        $seg = new Sistema_Model_DbTable_Catsegmento();
        $seg = $seg->fetchAll($seg->select()->where($where_seg)->order('CTS_ORD ASC'));
        foreach($seg as $s){
            $segmentos .= $s['CTS_NOM'].', ';
        }  
    }
    if($segmentos > '') $segmentos = substr($segmentos, 0, -2);
    
    $mdl = new Sistema_Model_DbTable_Modelagem();
    $mdl = $mdl->fetchRow('MDL_ID ='.$row['MDL_ID']);
    
    $tam = '';
    $ght = new Sistema_Model_DbTable_GradetamanhosHasTamanhos();
    $ght = $ght->fetchAll('GRA_ID ='.$row['GRA_ID']);
    foreach($ght as $g){
        $tm = new Sistema_Model_DbTable_Tamanhos();
        $tm = $tm->fetchRow('TAM_ID = '. $g['TAM_ID']);
        $tam .= $tm['TAM_NOM'].', ';
    } 
    if($tam > '') $tam = substr($tam, 0, -2);
?>
    <div class="item" style="height:100px">    
        <div class="col" style="width: 250px">
            <p><strong>Código: <?php echo $row['GRA_ID']; ?></strong></p>
            <p><strong>Título: </strong><?php echo $row['GRA_NOM']; ?></p>
            <p><strong>Status: </strong><?php echo tools::returnStatus($row['GRA_STA']); ?></p>
        </div>
        <div class="col" style="width: 200px">
            <p><strong>Segmento: </strong><?php echo $segmentos; ?></p>
            <p><strong>Modelagem: </strong><?php if($row['MDL_ID'] > 0) echo $mdl['MDL_NOM']; ?></p>
        </div>
        
        <div class="col" style="width: 150px">
            <p><strong>Tamanhos: </strong><?php echo $tam; ?></p>
            
        </div>
        
       
        
        <div class="btn-actions" style="padding-top: 10px;">
            <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['GRA_ID'])); ?>">Editar</a><?php }?>
            <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'medidas', 'id' => $row['GRA_ID'])); ?>">Medidas</a><?php }?>
        </div>

      </div>
    <?php } ?>
</div>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>